home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: Re: Urgent help needed
- Date: 6 Feb 1996 21:39:09 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4f8hpt$s0a@gail.ripco.com>
- NNTP-Posting-Host: foley.ripco.com
-
- randy@netspace.net.au (Patrick Liang)
- in <4f6v8q$ov6@otis.netspace.net.au> asks:
-
- >I am doing a program to convert a serial no to date format, the serial no is
- >representing the seconds elapsed since 01/01/1970. and I using the Visual basic
- >to call the DLL function(general from Borland C++ version 4).
-
- Since DLLs and WinDoze questions are implementation-details and not C,
- and Visual Basic is not C, I will ignore those aspects of your question.
- The following concerns your C code (the original of which is at EOM).
-
- Check the differences between the following and your code, and perhaps
- you will see something useful.
-
- #include <stdlib.h>
- #include <time.h>
- #include <stdio.h>
- #define FAR /* mha - added to ignore FAR */
- #define PASCAL /* mha - added to ignore PASCAL */
- char * FAR PASCAL NUMTODATE(char *argv1) /* mha - return type changed
- * from "char" to "char *" */
- {
- struct tm *ptr;
- char *c /* mha - ", buf1[80]" unused */;
- time_t l; /* mha - was "long" */
- l = atol(argv1); /* mha - (time_t) cast if you want */
- ptr = localtime(&l); /* mha - localtime takes a time_t arg,
- * which is only guaranteed to be an
- * arithmetic type capable of
- * representing times. The old
- * declaration of "long l;" clearly
- * won't do. */
- c = asctime(ptr);
- puts(c);
- return c; /* mha - was "return *c;" */
- }
-
-
- [ === randy's original C code ===]
- >/* this is the main c program Using Borland C++ */
-
- >/* Demonstrates the functions */
-
- >#include <stdio.h>
- >#include <time.h>
- >#include <stdlib.h>
- >#include <windows.h>
-
-
- >char FAR PASCAL NUMTODATE(char *argv1)
- >{
-
- > struct tm *ptr;
- > char *c, buf1[80];
- > long l;
-
- > l = atol(argv1);
-
- > ptr = localtime(&l);
-
- > c = asctime(ptr);
- > puts(c);
-
- > return *c;
- >}
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-